package com.xk.mapper;

import com.xk.pojo.Page;
import com.xk.pojo.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherMapper {
    @Select("select * from teacher;")
    List<Teacher> getAllTeachers();

    @Select("select * from teacher where TeacherID = #{id};")
    Teacher getTeacherById(Integer id);

    @Delete("DELETE FROM teacher WHERE TeacherID = #{id};")
    int deleteTeacherById(Integer id);

    //添加老师
    int addTeacher(Teacher teacher);

    int updateTeacherById(Teacher teacher);

    //获取第pageNumber页，每页显示的记录数为pageSize的教师列表,名字里包含search的
    @Select("SELECT * FROM teacher WHERE Name LIKE CONCAT('%', #{search}, '%') LIMIT #{pageNumber}, #{pageSize} ")
    List<Teacher> getTeacherListByPage(@Param("pageNumber") Integer pageNumber,
                                       @Param("pageSize")Integer pageSize,
                                       @Param("search")String search);


    @Select("SELECT * FROM teacher WHERE Name LIKE CONCAT('%', #{name}, '%')")
    List<Teacher> getTeacherByName(String name);

}
